
/* 
IV regressions
*/

set more off

estimates clear
clear

use ".\Dropbox\Vaccination\dma_sample.dta" // load the dataset

gen x=(statefips==48|statefips==15)  // identify states without the vaccination data

bysort google_dma: egen drop=max(x)
drop if drop==1 // drop DMAs crossing states without the vaccination data
drop if rep_house2016 ==. // drop DMAs without the house election data for consistency

zscore(rep*2016 vacc* america) //normalizing the variables

label variable z_rep_pres2016 "Trump vote share, 2016"
label variable z_rep_house2016 "Republican houseional vote share, 2016"
label variable z_america2014 "Search intensity: American vs. United States"

local DMA "lat lon temp rain income gini native_share white_share col_share elder_share male_share  mfg_share_diff popden" // geo and socio-economic controls

// Trump 
ivreg2 z_vaccinated_18pluspop_ratio (z_rep_pres2016=z_america2014) `DMA' i.division, robust 
estimates store trump1

// Trump and house
ivreg2 z_vaccinated_18pluspop_ratio (z_rep_pres2016=z_america2014)  z_rep_house2016 `DMA' i.division, robust 
estimates store trump2

// house
ivreg2 z_vaccinated_18pluspop_ratio (z_rep_house2016=z_america2014) `DMA' i.division, robust 
estimates store house1

// house and trump
ivreg2 z_vaccinated_18pluspop_ratio (z_rep_house2016=z_america2014) z_rep_pres2016 `DMA' i.division, robust 
estimates store house2

estout trump1 trump2 house1 house2 using ".\Dropbox\Vaccination\Draft\tab_iv.tex",  replace style(tex) cells(b(fmt(3) star) se(par fmt(3))) stats(widstat N, fmt(2 0) labels("Kleibergen-Paap F-stat" "Observations")) keep(z_rep_pres2016 z_rep_house2016) label mlabels(none) collabels(none) starlevels(* 0.10 ** 0.05 *** 0.01)